﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SCG.TurboSprite.TileBased
{
    public class Path
    {
        //Spawn a new Path from an existing one
        public Path(Tile startTile, Tile endTile)
        {
            _start = startTile;
            _end = endTile;
            Tiles = new List<Tile>();
        }
        public Path(Path path)
        {
            Tiles = new List<Tile>();
            foreach (Tile tile in path.Tiles)
                Tiles.Add(tile);
            Cost = path.Cost;
            _start = path._start;
            _end = path._end;
        }

        //The tiles in the path
        public List<Tile> Tiles { get; set; }

        //The cost of the path
        public double Cost { get; set; }

        //Does it end at the destination?
        public bool Completed
        {
            get
            {
                if (Tiles.Count == 0)
                    return false;
                return Tiles[Tiles.Count - 1] == _end;
            }
        }

        //Allow user to store data with paths
        public object Tag { get; set; }

        //For debugger
        public override string ToString()
        {
            string s = "";
            foreach (Tile t in Tiles)
                s += t.ToString() + ",";
            return s;
        }

        //private members
        private Tile _start;
        private Tile _end;
    }
}
